#ifndef __FIREWORKS_BLOCK_H__
#define __FIREWORKS_BLOCK_H__

#include "Block.hpp"

namespace PocketSurvival
{
	enum class Shape
	{
		SmallBurst,
		LargeBurst,
		Circle,
		Disc,
		Ball,
		ShortTrails,
		LongTrails,
		FlatTrails,


		ShapeCount
	};

    // 烟花
    class FireworksBlock : public Block
    {
    public:
        static constexpr int32_t Index()
        {
            return 215;
        }
        virtual int32_t getIndex() override; 
        virtual const std::string &getBlockName() override;

        virtual void getCreativeValues(std::vector<int32_t> &blockVec) override;

		static inline Shape GetShape(int32_t data);
		static inline int32_t SetShape(int32_t data, Shape shape);
		static inline int32_t GetAltitude(int32_t data);
		static inline int32_t SetAltitude(int32_t data, int32_t altitude);
		static inline bool GetFlickering(int32_t data);
		static inline int32_t SetFlickering(int32_t data, bool flickering);
		static inline int32_t GetColor(int32_t data);
		static inline int32_t SetColor(int32_t data, int32_t color);
    };

	inline Shape FireworksBlock::GetShape(int32_t data)
	{
		return (Shape)(data & 7);
	}

	inline int32_t FireworksBlock::SetShape(int32_t data, Shape shape)
	{
		return (data & -8) | ((int32_t)shape & (int32_t)Shape::FlatTrails);
	}

	inline int32_t FireworksBlock::GetAltitude(int32_t data)
	{
		return (data >> 3) & 1;
	}

	inline int32_t FireworksBlock::SetAltitude(int32_t data, int32_t altitude)
	{
		return (data & -9) | ((altitude & 1) << 3);
	}

	inline bool FireworksBlock::GetFlickering(int32_t data)
	{
		return ((data >> 4) & 1) != 0;
	}

	inline int32_t FireworksBlock::SetFlickering(int32_t data, bool flickering)
	{
		return (data & -17) | ((flickering ? 1 : 0) << 4);
	}

	inline int32_t FireworksBlock::GetColor(int32_t data)
	{
		return (data >> 5) & 7;
	}

	inline int32_t FireworksBlock::SetColor(int32_t data, int32_t color)
	{
		return (data & -225) | ((color & 7) << 5);
	}

} // namespace PocketSurvival


#endif
